package com.hundsun.fcp.adapter;

import com.hundsun.fcp.R;
import com.hundsun.fcp.bean.MineBean.MineItem;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;



public class MineListViewAdapter extends Adapter<MineItem> {

	public MineListViewAdapter(Context context) {
		super(context, R.layout.fragment_mine_item);
	}
	 
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null ;
		if(convertView == null){
			holder = new ViewHolder() ;
			convertView = mInflater.inflate(mLayoutResId, null) ;
			holder.mIconIm = (ImageView) convertView.findViewById(R.id.iv_icon) ;
			holder.mNameTv = (TextView) convertView.findViewById(R.id.tv_name) ;
			holder.mDescTv = (TextView) convertView.findViewById(R.id.tv_desc) ;
			holder.mLineView = convertView.findViewById(R.id.view_line) ;
			convertView.setTag(holder) ;
		}else{
			holder = (ViewHolder) convertView.getTag() ;
		}
		
		MineItem item = mDataList.get(position) ;
		holder.mIconIm.setImageResource(item.mImgResId) ;
		holder.mNameTv.setText(item.mNameResId) ;
		holder.mDescTv.setText(item.mDesc) ;
		if(position == mDataList.size()-1){
			holder.mLineView.setVisibility(View.GONE) ;
		}else{
			holder.mLineView.setVisibility(View.VISIBLE) ;
		}
		return convertView;
	}
	
	class ViewHolder{
		ImageView mIconIm ;
		TextView mNameTv ;
		TextView mDescTv ;
		View mLineView ;
	}

}
